2 Returns positive if a-b-c makes a left turn.
3 Returns negative if a-b-c makes a right turn.
4 Returns 0.0 if a-b-c are colineal.
6 double turn(const point
&a
, const point
&b
, const point
&c
){
7 double z
= (b
.x
- a
.x
)*(c
.y
- a
.y
) - (b
.y
- a
.y
)*(c
.x
- a
.x
);
8 if (fabs(z
) < 1e-9) return 0.0;
13 Returns true if polygon p is convex.
14 False if it's concave or it can't be determined
15 (For example, if all points are colineal we can't
18 bool isConvexPolygon(const vector
<point
> &p
){
21 for (int i
=0; i
<n
; ++i
){
24 double z
= turn(p
[i
], p
[j
], p
[k
]);
30 if (mask
== 3) return false;